using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using static COM_CODE;

public class AngleSensorRequest : MonoBehaviour
{
    public enum SENSOR_ID
    {
        SENSOR_1,
        SENSOR_2,
        SENSOR_3,
        SENSOR_4,
        SENSOR_5,
        SENSOR_6,
        SENSOR_7,
        SENSOR_ALL,
    }
    Analysis analysis;
    Action<object, object> handle;
    private void Awake()
    {
        analysis = GameObject.Find("GameObject").GetComponent<Analysis>();
    }
    /// <summary>
    /// 通过SENSOR_ID去请求指定的传感器角度
    /// </summary>
    /// <param name="_ID">SENSOR_ID 为SENSOR_ALL时获取所有值</param>
    /// <param name="callback">接收角度的回调函数，第一个参数为传感器id，第二个参数为传感器值</param>
    public void RequstSensorAngle(SENSOR_ID _ID)
    {
        if (handle == null)
        {
            Debug.Log("ERROR :Please SetSensorAngleHandle first!");
            return;
        }
        RequestCommand<int> command = new RequestCommand<int>(REQUEST_CODE.REQUEST_DATA,
                                                            TYPE_CODE.SENSOR_ANGLE,
                                                            (int)_ID,
                                                            this.handle);
        command.execute();
    }
    /// <summary>
    /// 设置角度传感器handle
    /// </summary>
    /// <param name="handle"> 回调函数</param>
    public void SetSensorAngleHandle(Action<object, object> handle)
    {
        this.handle = handle;
    }
}
